<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>协作申请管理-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">运营管理 > 协作申请管理</div>
		<div class="right">
			<div class="input-group left w250">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" placeholder="按单号搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
		</div>
	</div>
	<div id="content">
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="">协作申请编号</td>
					<td width="">项目编号</td>
					<td width="">项目经理/项目负责人</td>
					<td width="">协作工作性质</td>
					<td width="">需求部门</td>
					<td width="">联系电话</td>
					<td width="">申请人(日期)</td>
					<td width="">当前状态</td>
					<td width="90">
						<select name="state" class="w90">
							<option value="-10" <if condition="$state eq -10">selected</if>>状态</option>
							<option value="1" <if condition="$state eq 1">selected</if>>进行中</option>
							<option value="2" <if condition="$state eq 2">selected</if>>已完结</option>
						</select>
					</td>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td colspan="9" class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
				<tr>
					<td><a href="__APP__/Index/assist_apply_detail/id/{$vo['id']}/audit/audit/state/{$state}">{$vo['order_number']}</a></td>
					<td><span title="{$vo['project_name']}" data-placement="right" data-toggle="tooltip">{$vo['project_num']}</span></td>
					<td>{$vo['manager_name']}</td>
					<td>{$vo['work_nature']}</td>
					<td>{$vo['demand_depart']}</td>
					<td>{$vo['add_user_tele']}</td>
					<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
					<td>
						<if condition="$vo['status'] eq 1">待【项目负责人】审核
						<elseif condition="$vo['status'] eq 2"/>待【营销部负责人】审批
						<elseif condition="$vo['status'] eq 3"/>进行中
						<elseif condition="$vo['status'] eq 4"/>已完结
						</if>
					</td>
					<td class="nowrap">
						<if condition="($state eq 1 or $state eq -10) and ($vo['shenhe'] eq 1)">
							<if condition="$vo['status'] eq 2">
								<a href="javascript:;" status="{$vo['status']}" mid="{$vo['id']}" uuid="{$login_id}" data-toggle="tooltip" data-placement="left" title="审核" class="audit2 mr5"><i class="glyphicon glyphicon-ok"></i></a>
							<else/>
								<a href="javascript:;" status="{$vo['status']}" mid="{$vo['id']}" uuid="{$login_id}" data-toggle="tooltip" data-placement="left" title="审核" class="audit mr5"><i class="glyphicon glyphicon-ok"></i></a>
							</if>
							<a href="javascript:;" status="-1" mid="{$vo['id']}" uuid="{$login_id}" data-toggle="tooltip" data-placement="left" title="打回" class="back"><i class="glyphicon glyphicon-remove"></i></a>
						<elseif condition="($state eq 2 or $state eq -10 or $state eq 1) and ($vo['qishen'] eq 1) and ($vo['status'] neq 4)"/>
							<a href="javascript:;" status="{$vo['status']}" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="弃审" class="remove"><i class="glyphicon glyphicon-remove"></i></a>
						</if>
					</td>
				</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="edit-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>答复</strong></td>
						<td>
							<textarea name="text_hid" class="form-control required-text" style="width:100%; height:150px" autocomplete="off"></textarea>
							<input type="hidden" name="zxfzr_message">
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--打回弹框-->
<div class="modal fade" id="back-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>打回原因</strong></td>
						<td>
							<textarea name="dh_message" class="form-control required-text1" style="width:100%; height:150px" autocomplete="off"></textarea>
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm2">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$("[name='text_hid']").each(function(){
		var textss = $(this).text(),
			reg2 = new RegExp("<br/>", "g"),
			str = textss.replace(reg2, "\n");
		$(this).html(str);
	})
	//搜索
	$(".found_btn").keywordSearch("__APP__/Index/assist_apply_audit/keyword/$keyword/state/{$state}");

	//状态筛选
	$(document).on("change","[name='state']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Index/assist_apply_audit/keyword/{$keyword}/state/"+val;
	});
	//文本域暂存
	$("[name='text_hid']").blur(function(){
		var val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>");
		$("[name='zxfzr_message']").val(str);
	})
	
	$('.audit').on("click",function(){
		var status = parseInt($(this).attr('status'))+1,
			uuid = $(this).attr("uuid"),
			state = "{$state}",
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/assist_apply_audit_ajax",
			data:{"mid":mid,"status":status,"uuid":uuid,"state":state},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	//审核弹框
	$(".audit2").on("click",function(){
		var modal = $("#edit-modal"),
			mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = parseInt($(this).attr('status'))+1;
		modal.find(".modal-header h4").text("答复");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.find(".btn-affirm").attr({"mid":mid});
		modal.find(".btn-affirm").attr({"uuid":uuid});
		modal.find(".btn-affirm").attr({"status":status});
		modal.modal();
		modal.find("textarea").val('');
	});
	//取消
	$("#edit-modal").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	//审核
	$("#edit-modal").find(".btn-affirm").on("click",function(){
		var tag = false;
		$(".required-text").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		
		if(tag){
			return false;
		}else{
			var mid = $(this).attr("mid"),
				uuid = $(this).attr("uuid"),
				status = $(this).attr("status"),
				zxfzr_message = $("[name='zxfzr_message']").val(),
				modal = $("#edit-modal");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"zxfzr_message":zxfzr_message,"uuid":uuid,"status":status},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	$(document).on("focus",".required-text",function(){
		$(this).nextAll(".error-item").hide();
	});
	//打回
	$(".back").on("click",function(){
		var modal = $("#back-modal"),
			mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = $(this).attr("status");
		modal.find(".modal-header h4").text("打回");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.find(".btn-affirm2").attr({"mid":mid});
		modal.find(".btn-affirm2").attr({"uuid":uuid});
		modal.find(".btn-affirm2").attr({"status":status});
		modal.modal();
		modal.find("textarea").val('');
	});
	//取消
	$("#back-modal").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	$("#back-modal").find(".btn-affirm2").on("click",function(){
		var tag = false;
		$(".required-text1").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		
		if(tag){
			return false;
		}else{
			var mid = $(this).attr("mid"),
				uuid = $(this).attr("uuid"),
				status = $(this).attr("status"),
				dh_message = $("[name='dh_message']").val(),
				modal = $("#back-modal");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"dh_message":dh_message,"uuid":uuid,"status":status},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	$(document).on("focus",".required-text1",function(){
		$(this).nextAll(".error-item").hide();
	});
	//弃审
	$('.remove').on("click",function(){
		var status = $(this).attr('status'),
			state = 2,
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/assist_apply_audit_ajax",
			data:{"mid":mid,"status":status,"state":state},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
});
</script>
</body>
</html>